{% extends "group/group_base.html" %}
{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin %}
{% origin %}
{% load ietf_filters static %}
{% block pagehead %}
    <link rel="stylesheet" href="{% static "ietf/css/list.css" %}">
{% endblock %}
{% block group_subtitle %}Materials{% endblock %}
{% block group_content %}
    {% origin %}
    {% load ietf_filters %}
    {% if doc_types %}
        {% for doc_type, docs in doc_types %}
            <h2 class="mt-3">{{ doc_type.name }}</h2>
            <table class="table table-sm table-striped materials tablesorter">
                <thead>
                    <tr>
                        <th scope="col" data-sort="title">Title</th>
                        <th scope="col" data-sort="abstract">Abstract</th>
                        <th scope="col" data-sort="num">Curr. rev.</th>
                        <th scope="col" data-sort="date">Date</th>
                        <th scope="col" data-sort="last">Last presented</th>
                        <th scope="col" data-sort="on">On agenda</th>
                    </tr>
                </thead>
                <tbody>
                    {% for d in docs %}
                        <tr>
                            <td>
                                <a class="title-link"
                                   href="{% url "ietf.doc.views_doc.document_main" name=d.name %}">{{ d.title }}</a>
                            </td>
                            <td class="snippable">{{ d.abstract|urlize_ietf_docs|format_snippet }}</td>
                            <td>{{ d.rev }}</td>
                            <td>{{ d.time|date:"Y-m-d" }}</td>
                            <td>
                                {% regroup d.last_presented by session.meeting as past_pres_list %}
                                {% for p in past_pres_list %}
                                    {{ p.grouper }}
                                    {% if p.list|length > 1 %}
                                        <span class="badge rounded-pill text-bg-info">{{ p.list|length }} sessions</span>
                                    {% else %}
                                        {% for pr in p.list %}
                                            {% if pr.rev != d.rev %}(-{{ pr.rev }}){% endif %}
                                        {% endfor %}
                                    {% endif %}{% if not forloop.last %},{% endif %}
                                {% endfor %}
                            </td>
                            <td>
                                {% regroup d.future_presentations by session.meeting as meeting_pres_list %}
                                {% for p in meeting_pres_list %}
                                    {{ p.grouper }}
                                    {% if p.list|length > 1 %}
                                        <span class="badge rounded-pill text-bg-info">{{ p.list|length }} sessions</span>
                                    {% else %}
                                        {% for pr in p.list %}
                                            {% if pr.rev != d.rev %}(-{{ pr.rev }}){% endif %}
                                        {% endfor %}
                                    {% endif %}{% if not forloop.last %},{% endif %}
                                {% endfor %}
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        {% endfor %}
    {% else %}
        <h2>Materials</h2>
        <p>
            No materials uploaded.
        </p>
    {% endif %}
{% endblock %}
{% block js %}
    <script src="{% static "ietf/js/list.js" %}"></script>
{% endblock %}